package com.le.tester.book.effectivejava3rdchinese.articlethirtyserven;

import java.util.EnumMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * createTime：2022/8/22 9:46
 * description：Plant
 */
public class Plant {
    enum LifeCycle {
        ANNUAL, PERENNIAL, BIENNIAL
    }

    final String name;

    final LifeCycle lifeCycle;

    Plant(String name, LifeCycle lifeCycle) {

        this.name = name;
        this.lifeCycle = lifeCycle;
    }


//    Set<Plant>[] plantsByLifeCycle
//            = (Set<Plant>[]) new Set[LifeCycle.values().length];

    Map<Plant.LifeCycle, Set<Plant>> plantLifeCycle = new EnumMap<>(Plant.LifeCycle.class);

    public void demo() {
        for (Plant.LifeCycle lc : Plant.LifeCycle.values()) {
            plantLifeCycle.put(lc, new HashSet<>());
        }
    }



    @Override
    public String toString() {
        return "Plant{" +
                "name='" + name + '\'' +
                '}';
    }
}
